package Stack_Queue;

import java.util.Stack;

public class lc232 {

}

class MyQueue{
    Stack<Integer> instack;
    Stack<Integer> outstack;
    public MyQueue() {
        instack=new Stack<>();
        outstack=new Stack<>();

    }

    public void push(int x) {
        instack.push(x);
    }

    public int pop() {
        if(outstack.empty()){
            while(!instack.empty()){
                int out= instack.pop();
                outstack.push(out);
            }
        }

        return outstack.pop();

    }

    public int peek() {
        if(outstack.empty()){
            while(!instack.empty()){
                int out= instack.pop();
                outstack.push(out);
            }
        }
        return outstack.peek();
    }

    public boolean empty() {
        if(instack.empty()&& outstack.empty())
        return true;

        return false;
    }
}
